package birdsong.comm;

import java.io.Serializable;

/**
 * 
 * Implements the ServerSideMessage and Serializable. This class represents the
 * message that a client wants to send to the server.
 * 
 * @see {@link ServiceSideMessages} to know what types of messages exists.
 */
public class ServerMessage implements ServerSideMessage, Serializable {

	private static final long serialVersionUID = 1L;
	private final Type messageType;
	private final String payload;
	private final String nickname;

	/**
	 * Constructor.
	 * 
	 * @param messageType - type of message. See ClientSideMessage for more information about the types.
	 * @param payload - Data to send to client.
	 * @param nickname - Name of client.
	 */
	public ServerMessage(Type messageType, String payload, String nickname) {
		this.messageType = messageType;
		this.payload = payload;
		this.nickname = nickname;
	}

	/**
	 * Returns the message type.
	 */
	@Override
	public Type getType() {
		return messageType;
	}

	/**
	 * Returns the message payload.
	 */
	@Override
	public String getPayload() {
		return payload;
	}

	/**
	 * Returns the name of the client.
	 */
	@Override
	public String getClientNickname() {
		return nickname;
	}

}
